﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace WeatherFrame
{
	public partial class SunIcon : UserControl
	{
        public SunIcon()
		{
			// Required to initialize variables
			InitializeComponent();
            SunPath.Data = Sun();
		}


        PathFigure Ray(double length) {
            return new PathFigure {
                StartPoint = new Point(0,-50), IsClosed = true,
                Segments = { 
                    new LineSegment { Point = new Point(-5,-50+length) },
                    new LineSegment { Point = new Point(5,-50+length) },
                }                
            };
        }

        Point pt1 = new Point(-5, -34);
        Point pt2 = new Point(5, -34);

        PathFigure Ray16()
        {
            return new PathFigure
            {
                StartPoint = new Point(0, -50),
                IsClosed = true,
                Segments = { 
                    new LineSegment { Point = pt1 },
                    new LineSegment { Point = pt2 }
                }
            };
        }


        static GeometryGroup sun;
        GeometryGroup Sun()
        {
            //if (sun == null)
            //{
                sun = new GeometryGroup();
                sun.Children.Add(new EllipseGeometry { RadiusX = 30, RadiusY = 30 });
                for (int i = 0; i < 12; i++)
                {
                    sun.Children.Add(
                        new PathGeometry
                        {
                            Figures = { Ray16() },
                            Transform = new RotateTransform { Angle = 15 + 30 * i }
                        });
                }
            //}
            return sun;
        }
    }
}